# Maintainer: Ray Donnelly <mingw.android@gmail.com>

_realname=rhash
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.3.6
pkgrel=1
pkgdesc="Great utility for computing hash sums (mingw-w64)"
arch=('any')
url='https://sourceforge.net/projects/rhash/'
depends=("${MINGW_PACKAGE_PREFIX}-gettext")
makedepends=("${MINGW_PACKAGE_PREFIX}-ruby")
license=('custom' 'MIT')
source=(https://downloads.sourceforge.net/rhash/${_realname}-$pkgver-src.tar.gz{,.asc}
        001-mingw.patch)
sha256sums=('964df972b60569b5cb35ec989ced195ab8ea514fc46a74eab98e86569ffbcf92'
            'SKIP'
            '0de7aa61dfe43fe7ed453d807c10604e1bcd664867b67b13c46a33efe9bc7480')
validpgpkeys=('2875F6B1C2D27A4F0C8AF60B2A714497E37363AE')

prepare() {
  cd ${_realname}-${pkgver}
  patch -Nbp1 -i ${srcdir}/001-mingw.patch
}

build() {
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  cp -R "${srcdir}"/RHash-${pkgver} "${srcdir}"/build-${CARCH}
  cd "${srcdir}"/build-${CARCH}
  ./configure \
     --prefix=${MINGW_PREFIX} \
     --enable-lib-static \
     --enable-lib-shared
  make
}

check() {
  cd "${srcdir}"/build-${CARCH}
  make test test-shared test-static
}

package() {
  cd "${srcdir}"/build-${CARCH}
  make -j1 install DESTDIR="${pkgdir}"
  make -j1 install install-gmo

  # license
  # fully qualify path for this because there might be switch in
  # build systems.
  install -Dm644 ${srcdir}/RHash-${pkgver}/COPYING \
    "$pkgdir${MINGW_PREFIX}"/share/licenses/rhash/LICENSE
}
